"""author: wenyao
   data: 2020/11/11
   project: ludingji
"""
# 高阶函数
# 把函数作为参数传入，这样的函数称为高阶函数，
# def  func01(a,b):
#     print(f"{a} {b}")
#
# def func02(func,a,b):
#     print("start func......")
#     func(a,b)
#
# func01("x","y") # 位置参数
# func01(b="bb",a="aa") #关键字参数
# func02(func01,"x","y")

#########map
#映射
# def func(item):
#     return item*item
#
# a = [1,2,3,4,5,6]
# # result = map(func, a)
# result = map(lambda x:x*x, a)
# print(result)
# print(list(result))

#保留两位小数
# b = [1.239865,4.56,3.2,9.82356]
# result = map(lambda x:'%.2f'%x,b)
# result = map(lambda x:round(x,2),b)
# print(list(result))

#转化为百分数，并且保留两位小数
# c = [0.000564,0.456723,0.5,0.71345]
# result = map(lambda x:format(x,'.2%'),c)
# result = map(lambda x:'%.2f%%'%(x*100),c)
# print(list(result))

# a = [1,2,3,4,5]
# result = map(lambda x:str(x),a)
# print(list(result))
#
# a = "span"
# result = map(lambda x:ord(x),a)
# print(list(result))
#
# a = [-1,-2,0,1,2]
# result = map(lambda x:abs(x),a)
# print(list(result))

##########filter
#过滤
#保留奇数
# a=[1,2,3,4,5,6,7,8]
# def func01(x):
#     return x%2 == 1
#
# result = filter(func01, a)
# print(list(result))

#返回100以内的回数
#回数从左至右和从右到左都是一样的数
# b = range(1,100+1)
# def func02(x):
#     #return x%11 == 0
#      return str(x) == str(x)[::-1]
# result = filter(func02,b)
# print(list(result))

#math.sqrt
import math
from math import sqrt
#过滤出1-100以内开平方根是整数的数
# a = []
# for i in range(1,101):
#     a.append(i)
# result = filter(lambda x:str(x)==str(x)[::-1],a)
# print(list(result))
# def func02(x):
#     result = int(sqrt(x))
#     return result*result == x
#
# result = filter(lambda x:math.sqrt(x) in range(1,11) ,a)
# print(list(result))
#
#  把一个序列中的空字符串删掉，['A', '', 'B', None, 'C', '  ', 'a', 1, 0]
# ['A', 'B', 'C', 'a', 1]


# import re
# list5 = ["A","","B",None,"C","a",1,0," "]
# print(list(filter(lambda x:x and str(x).strip(),list5)))

#水仙花数  100-999以内的水仙花数
#水仙花数153 = 1的三次方+5的三次方+3的三次方
# def func01(x):
#     num = str(x)
#     return int(num[0])**3 + int(num[1])**3 + int(num[2])**3 == x
#
# result = filter(lambda x:(x//100)**3+(x//10%10)**3+(x%10)**3==x,range(100,1000))
# result = filter(func01,range(100,1000))
# print(list(result))


#reduce
# a = [1,2,3,4] #-->1234
#方法一：
# a = [1,2,3,4]
# result = map(lambda x:str(x),a)
# b = list(result)
# print(b)
# c=''
# for i in b:
#     c+=i
# print(int(c))
#
# b = int("".join(map(str,a)))
#方法二：
# a = [1,2,3,4]
# b = a[::-1]
# print(b)
# c=0
# for i in range(len(b)):
#     c +=b[i]*10**i
# print(c)

from functools import reduce
a = [1,2,3,4]
def func1(x,y):
    return x*10+y
print(reduce(func1,a))

#第一次执行传参
#func1  传参 1 2  返回12
#第二次执行传参  12  3  返回123
#第三次传参   123  4  返回1234

# def func1(x,y):
#     return x+y
# a='123'
# print(type(reduce(func1,a)))


#str --> int(自己实现int函数的功能)
# a = {"0":0,"1":1,"2":2,"3":3}
# print(type(a.get("1")))

# a = input("输入想要转化的数字：")
# b = {'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'0':0}
# c = list(map(lambda i:b.get(i),a))
# print(c)
# def func(x,y):
#     return x*10+y
# result = reduce(func,c)
# print(result,type(result))

# a = {"0":0,"1":1,"2":2,"3":3}
# d=0
# def func1(x,y):
#     global d
#     if len(x+y) == len(b):
#         for i in range(len(x+y)):
#             print(x+y)
#             d+=a.get((x+y)[::-1][i])*10**i
#         return d
#     return x+y
#
# b='123'
# print(reduce(func1,b))
# print(type(reduce(func1,b)))

#sorted 排序
#用key来执行排序规则函数，只能传一个参数

#
# sorted 排序类型一致
# >>> a = [1,2,4,3,0]
# >>> sorted(a)
# [0, 1, 2, 3, 4]
# >>> a.sort()
# >>> a
# [0, 1, 2, 3, 4]
# >>> a = [1,2,4,3,0]
# >>> sorted(a)
# [0, 1, 2, 3, 4]
# >>> a.append("10")
# >>> sorted(a)
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: '<' not supported between instances of 'str' and 'int'


#全为布尔型 可以排序
# >>> a = [1,True,0,False,"c"=="c"]
# >>> sorted(a)
# [0, False, 1, True, True]


#按照字符串长度排序
# >>> a = ["abc","defg","123456","1","sbbbfg"]
# >>> sorted(a)
# ['1', '123456', 'abc', 'defg', 'sbbbfg']
# >>> sorted(a,key=len)
# ['1', 'abc', 'defg', '123456', 'sbbbfg']

#忽略大小写进行排序
#序列：['bob', 'about', 'Zoo', 'Credit']
# >>> sorted(a,key=str.lower)
# ['about', 'bob', 'Credit', 'Zoo']

#元组的排序，先比较第一个值，再比较第二个，依次类推
# >>> a=[(1,2),(2,2),(1,0),(2,4),(True,False)]
# >>> sorted(a)
# [(1, 0), (True, False), (1, 2), (2, 2), (2, 4)]

#反序  reverse=True
# >>> sorted(a,reverse=True)
# [(2, 4), (2, 2), (1, 2), (1, 0), (True, False)]

#验证用户名
#[123,abcefgh]  -->[123不符合规范，abcefgh符合规范]

lst = ["wy123456_789","123","wy#1234567","123wyyyyyyyyyyyyyyyyy"]
#-->["wy123456_789符合规范"，"123不符合规范"....]
import re
# def func01(x):
#     if  re.findall('^[a-zA-Z_]\w{5,17}$',x):
#         return f"{x}符合规范"
#     else:
#         return f"{x}不符合规范"
#
# result = map(func01,lst)
# print(list(result))

# print(list(filter(lambda x:re.findall('^[a-zA-Z_]\w{5,17}$',x),lst)))

# import re
# username1=["1asdfg","asdfgh ","_asdfgh","@asdfg","asdfghj"]
# def func1(x):
#     if re.findall(r'^[^0-9]\w{5,17}',x):
#         return f"{x}yes"
#     else:
#         return f"{x}no"
#
# print(list(map(func1,username1)))

#实现阶乘
n = int(input("输入"))
redu =reduce(lambda x,y:x*y,range(1,n+1))
print(redu)